<%
Class FastAsp_Session
    Private m_Prefix    'Session前缀
    Private m_Timeout   'Session超时时间(分钟)
    
    Private Sub Class_Initialize()
        m_Prefix = "FA_"
        m_Timeout = Session.Timeout
    End Sub
    
    '设置Session
    Public Function Set_(byval name, byval value)
        Session(m_Prefix & name) = value
        Set Set_ = Me
    End Function
    
    '获取Session
    Public Function [Get](byval name)
        [Get] = Session(m_Prefix & name)
    End Function
    
    '删除Session
    Public Function Delete(byval name)
        Session.Contents.Remove(m_Prefix & name)
        Set Delete = Me
    End Function
    
    '清空所有Session
    Public Function Clear()
        Session.Abandon
        Set Clear = Me
    End Function
    
    '设置Session前缀
    Public Function Prefix(byval value)
        m_Prefix = value
        Set Prefix = Me
    End Function
    
    '设置Session超时时间(分钟)
    Public Function Timeout(byval value)
        Session.Timeout = value
        m_Timeout = value
        Set Timeout = Me
    End Function
    
    '判断Session是否存在
    Public Function Has(byval name)
        Has = Not IsEmpty(Session(m_Prefix & name))
    End Function
    
    '获取所有Session
    Public Function All()
        Dim dict : Set dict = Server.CreateObject("Scripting.Dictionary")
        Dim key
        For Each key In Session.Contents
            If Left(key, Len(m_Prefix)) = m_Prefix Then
                dict.Add Mid(key, Len(m_Prefix) + 1), Session(key)
            End If
        Next
        Set All = dict
    End Function
End Class
%> 